HAL SAI control functions migration ¶
This section provides information about the HAL SAI control function migration.
HAL SAI initialization protocol function ¶
|
HAL1 |
HAL2 |
|---|---|
|
In HAL1, the HAL_SAI_InitProtocol() function initializes FrameInit, SlotInit, and the lower part of the Init structure based on the protocol using:
and the protocol data size using:
and nbslot parameter, providing protocol-specific defaults for I2S and PCM audio formats. |
In HAL2, this function has been removed, and the user can configure the SAI protocol using:
and the data size using:
and nbslot parameter within the HAL_SAI_SetConfig() function. |
HAL_SAI_InitProtocol(&hSAI1_A, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_16BIT, 2);
and HAL_SAI_InitProtocol(&hSAI1_A, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_16BITEXTENDED, 2);
|
sai_config.protocol = HAL_SAI_PROTOCOL_FREE;
..
sai_config.data_size = HAL_SAI_DATA_SIZE_16BITS;
..
sai_config.slot.slot_number = 2;
HAL_SAI_SetConfig(&hSAI1_A, &sai_config);
|
HAL_SAI_InitProtocol(&hSAI1_A, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_24BIT, 2);
|
sai_config.protocol = HAL_SAI_PROTOCOL_FREE;
..
sai_config.data_size = HAL_SAI_DATA_SIZE_24BITS;
..
sai_config.slot.slot_number = 2;
HAL_SAI_SetConfig(&hSAI1_A, &sai_config);
|
HAL_SAI_InitProtocol(&hSAI1_A, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_32BIT, 2);
|
sai_config.protocol = HAL_SAI_PROTOCOL_FREE;
..
sai_config.data_size = HAL_SAI_DATA_SIZE_32BITS;
..
sai_config.slot.slot_number = 2;
HAL_SAI_SetConfig(&hSAI1_A, &sai_config);
|
HAL_SAI_InitProtocol(&hSAI1_A, SAI_I2S_MSBJUSTIFIED, SAI_PROTOCOL_DATASIZE_16BIT, 2);
and HAL_SAI_InitProtocol(&hSAI1_A, SAI_I2S_MSBJUSTIFIED, SAI_PROTOCOL_DATASIZE_16BITEXTENDED, 2);
|
sai_config.protocol = HAL_SAI_PROTOCOL_FREE;
..
sai_config.data_size = HAL_SAI_DATA_SIZE_16BITS;
..
sai_config.slot.slot_number = 2;
HAL_SAI_SetConfig(&hSAI1_A, &sai_config);
|
HAL_SAI_InitProtocol(&hSAI1_A, SAI_I2S_MSBJUSTIFIED, SAI_PROTOCOL_DATASIZE_24BIT, 2);
|
sai_config.protocol = HAL_SAI_PROTOCOL_FREE;
..
sai_config.data_size = HAL_SAI_DATA_SIZE_24BITS;
..
sai_config.slot.slot_number = 2;
HAL_SAI_SetConfig(&hSAI1_A, &sai_config);
|
HAL_SAI_InitProtocol(&hSAI1_A, SAI_I2S_MSBJUSTIFIED, SAI_PROTOCOL_DATASIZE_32BIT, 2);
|
sai_config.protocol = HAL_SAI_PROTOCOL_FREE;
..
sai_config.data_size = HAL_SAI_DATA_SIZE_32BITS;
..
sai_config.slot.slot_number = 2;
HAL_SAI_SetConfig(&hSAI1_A, &sai_config);
|
HAL_SAI_InitProtocol(&hSAI1_A, SAI_I2S_LSBJUSTIFIED, SAI_PROTOCOL_DATASIZE_16BIT, 2);
and HAL_SAI_InitProtocol(&hSAI1_A, SAI_I2S_LSBJUSTIFIED, SAI_PROTOCOL_DATASIZE_16BITEXTENDED, 2);
|
sai_config.protocol = HAL_SAI_PROTOCOL_FREE;
..
sai_config.data_size = HAL_SAI_DATA_SIZE_16BITS;
..
sai_config.slot.slot_number = 2;
HAL_SAI_SetConfig(&hSAI1_A, &sai_config);
|
HAL_SAI_InitProtocol(&hSAI1_A, SAI_I2S_LSBJUSTIFIED, SAI_PROTOCOL_DATASIZE_24BIT, 2);
|
sai_config.protocol = HAL_SAI_PROTOCOL_FREE;
..
sai_config.data_size = HAL_SAI_DATA_SIZE_24BITS;
..
sai_config.slot.slot_number = 2;
HAL_SAI_SetConfig(&hSAI1_A, &sai_config);
|
HAL_SAI_InitProtocol(&hSAI1_A, SAI_I2S_LSBJUSTIFIED, SAI_PROTOCOL_DATASIZE_32BIT, 2);
|
sai_config.protocol = HAL_SAI_PROTOCOL_FREE;
..
sai_config.data_size = HAL_SAI_DATA_SIZE_32BITS;
..
sai_config.slot.slot_number = 2;
HAL_SAI_SetConfig(&hSAI1_A, &sai_config);
|
HAL_SAI_InitProtocol(&hSAI1_A, SAI_PCM_SHORT, SAI_PROTOCOL_DATASIZE_16BIT, 2);
and HAL_SAI_InitProtocol(&hSAI1_A, SAI_PCM_SHORT, SAI_PROTOCOL_DATASIZE_16BITEXTENDED, 2);
|
sai_config.protocol = HAL_SAI_PROTOCOL_FREE;
..
sai_config.data_size = HAL_SAI_DATA_SIZE_16BITS;
..
sai_config.slot.slot_number = 2;
HAL_SAI_SetConfig(&hSAI1_A, &sai_config);
|
HAL_SAI_InitProtocol(&hSAI1_A, SAI_PCM_SHORT, SAI_PROTOCOL_DATASIZE_24BIT, 2);
|
sai_config.protocol = HAL_SAI_PROTOCOL_FREE;
..
sai_config.data_size = HAL_SAI_DATA_SIZE_24BITS;
..
sai_config.slot.slot_number = 2;
HAL_SAI_SetConfig(&hSAI1_A, &sai_config);
|
HAL_SAI_InitProtocol(&hSAI1_A, SAI_PCM_SHORT, SAI_PROTOCOL_DATASIZE_32BIT, 2);
|
sai_config.protocol = HAL_SAI_PROTOCOL_FREE;
..
sai_config.data_size = HAL_SAI_DATA_SIZE_32BITS;
..
sai_config.slot.slot_number = 2;
HAL_SAI_SetConfig(&hSAI1_A, &sai_config);
|
HAL_SAI_InitProtocol(&hSAI1_A, SAI_PCM_LONG, SAI_PROTOCOL_DATASIZE_16BIT, 2);
and HAL_SAI_InitProtocol(&hSAI1_A, SAI_PCM_LONG, SAI_PROTOCOL_DATASIZE_16BITEXTENDED, 2);
|
sai_config.protocol = HAL_SAI_PROTOCOL_FREE;
..
sai_config.data_size = HAL_SAI_DATA_SIZE_16BITS;
..
sai_config.slot.slot_number = 2;
HAL_SAI_SetConfig(&hSAI1_A, &sai_config);
|
HAL_SAI_InitProtocol(&hSAI1_A, SAI_PCM_LONG, SAI_PROTOCOL_DATASIZE_24BIT, 2);
|
sai_config.protocol = HAL_SAI_PROTOCOL_FREE;
..
sai_config.data_size = HAL_SAI_DATA_SIZE_24BITS;
..
sai_config.slot.slot_number = 2;
HAL_SAI_SetConfig(&hSAI1_A, &sai_config);
|
HAL_SAI_InitProtocol(&hSAI1_A, SAI_PCM_LONG, SAI_PROTOCOL_DATASIZE_32BIT, 2);
|
sai_config.protocol = HAL_SAI_PROTOCOL_FREE;
..
sai_config.data_size = HAL_SAI_DATA_SIZE_32BITS;
..
sai_config.slot.slot_number = 2;
HAL_SAI_SetConfig(&hSAI1_A, &sai_config);
|
HAL SAI PDM microphone delay configuration function ¶
|
HAL1 |
HAL2 |
|---|---|
HAL_SAIEx_ConfigPdmMicDelay(const SAI_HandleTypeDef *hsai,
const SAIEx_PdmMicDelayParamTypeDef *pdmMicDelay);
|
HAL_SAI_SetPdmMicDelay(const hal_sai_handle_t *hsai,
const hal_sai_pdm_mic_delay_t *p_pdm_mic_delay);
|
Related concepts: Merge HAL extension files with common ones and remove the EX prefix from APIs.
HAL SAI block synchronization configuration function ¶
|
HAL1 |
HAL2 |
|---|---|
SAI_BlockSynchroConfig(const SAI_HandleTypeDef *hsai);
|
This function is removed in HAL2, use instead Synchronization and Synchronization output functions: HAL_SAI_SetSyncOutput(hal_sai_handle_t *hsai, hal_sai_sync_output_t sync_output);
HAL_SAI_SetSync(hal_sai_handle_t *hsai, hal_sai_sync_t sync);
See HAL SAI initialization type definition for more details. |
HAL SAI input clock frequency retrieval function ¶
|
HAL1 |
HAL2 |
|---|---|
SAI_GetInputClock(const SAI_HandleTypeDef *hsai);
|
HAL_SAI_GetClockFreq(const hal_sai_handle_t *hsai);
|